import { defineStore } from 'pinia'
import { Local } from '@/utils/storage'
import { nextTick } from 'vue'

/**
 * 系统布局配置
 */
export const useLayoutConfigStore = defineStore('layoutConfig', {
    state: ():LayoutConfigState => {
        return {
            isCollapse: false,
            globalTitle: '梦学谷-Vue3全家桶项目',
            isFullscreen: false,
            isDark: false
        }
    },
    getters: {

    },
    actions: {
        updateState(state: LayoutConfigState) {
            // 将传递的参数更新到 state 状态中
            this.$patch(state)
        }
    }
})

nextTick(() =>{
    const layoutConfig = useLayoutConfigStore()
    layoutConfig.$subscribe((mutation, state) => {
        Local.set('layoutConfig', state)
    })
})